<?php if (!defined('THINK_PATH')) exit(); /*a:1:{s:89:"/Users/juyaobin/Desktop/clover_download/application/bbs/view/loginandreg/loginandreg.html";i:1561092535;}*/ ?>
<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport"
        content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
    <title>登录</title>
    <link rel="stylesheet" href="/public/bbs/loginandreg/css/login.css">
    <link rel="stylesheet" href="/public/bbs/loginandreg/css/sign-up-login.css">
    <link rel="stylesheet" href="/public/bbs/loginandreg/css/inputEffect.css" />
    <link rel="stylesheet" href="/public/bbs/loginandreg/css/verifyCode.css" />
    <link rel="stylesheet" href="/public/bbs/loginandreg/css/tooltips.css " />
    <link rel="stylesheet" href="/public/bbs/loginandreg/css/font-awesome.4.6.0.css " />
    <link rel="stylesheet" href="/public/bbs/loginandreg/css/spop.min.css">
    <script src="/public/bbs/loginandreg/js/jquery-3.4.1.min.js"></script>
    <script src="/public/bbs/loginandreg/js/jquery.pure.tooltips.js"></script>
    <script src="/public/bbs/loginandreg/js/spop.min.js"></script>
    <script src="/public/bbs/loginandreg/js/snow.js"></script>
    <script src="/public/jquery/jquery.md5.js"></script>
    <script src="/public/rsa/jsencrypt.js"></script>
    <script>
        function GetQrcode() {
            $.ajax({
                type: "POST",
                url: "<?php echo url('bbs/loginandreg/GetQrcode'); ?>",
                data: {},
                dataType: "JSON",
                success: function (response) {
                    $("#qrcode1").attr('src', response.data.base64_img);
                    $("#qrcode2").attr('src', response.data.base64_img);
                    $("#qrcode3").attr('src', response.data.base64_img);
                }
            });
        }

        function GetCode(input_id) {
            $.ajax({
                type: "POST",
                url: "<?php echo url('bbs/loginandreg/SonVerificationCode'); ?>",
                data: {
                    email: encodeURIComponent(rsa_encode($('#' + input_id).val(),
                        '<?php echo $bbs_settings['rsa_public']; ?>')),
                    input_id: input_id,
                },
                dataType: "json",
                success: function (response) {
                    if (response.code == 0) {


                        var number = 899;

                        $(document).ready(function () {
                            //循环执行，每隔1秒钟执行一次 1000 
                            var t1 = window.setInterval(refreshCount, 1000);

                            function refreshCount() {
                                //循环执行，每隔1秒钟执行一次 1000 
                                if (number == 0) {
                                    window.clearInterval(t1);
                                    $('#Button_' + input_id).html('获取验证码');
                                    $('#Button_' + input_id).attr('disabled', false);
                                    $('#Button_' + input_id).css({
                                        "background-color": "#428bca",
                                    });
                                    number--;
                                } else {
                                    $('#Button_' + input_id).html("请在" + number + "s重新获取");
                                    $('#Button_' + input_id).attr('disabled', true);
                                    $('#Button_' + input_id).css({
                                        "background-color": "#98bf21",
                                    });
                                    number--;
                                }
                            }
                        });

                        $(document).ready(function () {

                        });
                    } else {
                        alert('发生意外错误错误代码' + response.code + '可能原因' + response.ErrorMsg)
                    }
                }
            });
        }
        (function () {
            // trim polyfill : https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/Trim
            if (!String.prototype.trim) {
                (function () {
                    // Make sure we trim BOM and NBSP
                    var rtrim = /^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g;
                    String.prototype.trim = function () {
                        return this.replace(rtrim, '');
                    };
                })();
            }

            [].slice.call(document.querySelectorAll('input.input__field')).forEach(function (inputEl) {
                // in case the input is already filled..
                if (inputEl.value.trim() !== '') {
                    classie.add(inputEl.parentNode, 'input--filled');
                }

                // events:
                inputEl.addEventListener('focus', onInputFocus);
                inputEl.addEventListener('blur', onInputBlur);
            });

            function onInputFocus(ev) {
                classie.add(ev.target.parentNode, 'input--filled');
            }

            function onInputBlur(ev) {
                if (ev.target.value.trim() === '') {
                    classie.remove(ev.target.parentNode, 'input--filled');
                }
            }
        })();

        $(function () {
            $('#login #login-password').focus(function () {
                $('.login-owl').addClass('password');
            }).blur(function () {
                $('.login-owl').removeClass('password');
            });
            $('#login #register-password').focus(function () {
                $('.register-owl').addClass('password');
            }).blur(function () {
                $('.register-owl').removeClass('password');
            });
            $('#login #register-repassword').focus(function () {
                $('.register-owl').addClass('password');
            }).blur(function () {
                $('.register-owl').removeClass('password');
            });
            $('#login #forget-password').focus(function () {
                $('.forget-owl').addClass('password');
            }).blur(function () {
                $('.forget-owl').removeClass('password');
            });
        });

        function goto_register() {
            $("#register-username").val("");
            $("#register-password").val("");
            $("#register-repassword").val("");
            $("#register-code").val("");
            $("#tab-2").prop("checked", true);
        }

        function goto_login() {
            $("#login-username").val("");
            $("#login-password").val("");
            $("#tab-1").prop("checked", true);
        }

        function goto_forget() {
            $("#forget-username").val("");
            $("#forget-password").val("");
            $("#forget-code").val("");
            $("#tab-3").prop("checked", true);
        }

        function login() { //登录
            var username = $("#login-username").val(),
                password = $("#login-password").val(),
                verifycode = $("#login-verify-code").val(),
                validatecode = null;
            //判断用户名密码是否为空
            if (username == "") {
                $.pt({
                    target: $("#login-username"),
                    position: 'r',
                    align: 't',
                    width: 'auto',
                    height: 'auto',
                    content: "用户名不能为空"
                });
                return;
            }
            if (password == "") {
                $.pt({
                    target: $("#login-password"),
                    position: 'r',
                    align: 't',
                    width: 'auto',
                    height: 'auto',
                    content: "密码不能为空"
                });
                return;
            }
            if (verifycode == "") {
                $.pt({
                    target: $("#login-verify-code"),
                    position: 'r',
                    align: 't',
                    width: 'auto',
                    height: 'auto',
                    content: "验证码不能为空"
                });
                return;
            }
            $.ajax({
                type: "POST",
                url: "<?php echo url('bbs/loginandreg/login'); ?>",
                data: {
                    username: encodeURIComponent(rsa_encode(username, '<?php echo $bbs_settings['rsa_public']; ?>')),
                    password: encodeURIComponent(rsa_encode($.md5(password), '<?php echo $bbs_settings['rsa_public']; ?>')),
                    verifycode: verifycode,
                },
                dataType: "json",
                success: function (response) {
                    if (response.code == 0) {
                        alert('登录成功');
                        window.location.href = "<?php echo $go_href; ?>";
                    } else {
                        $.pt({
                            target: $("#" + response.tips),
                            position: 'r',
                            align: 't',
                            width: 'auto',
                            height: 'auto',
                            content: response.ErrorMsg
                        });
                    }

                }
            });

            return false;
        }

        //注册
        function register() {
            var username = encodeURIComponent(rsa_encode($("#Register_Email").val(), '<?php echo $bbs_settings['rsa_public']; ?>')),
                RegisterCode = encodeURIComponent(rsa_encode($("#register-code").val(), '<?php echo $bbs_settings['rsa_public']; ?>')),
                password = encodeURIComponent(rsa_encode($("#register-password").val(), '<?php echo $bbs_settings['rsa_public']; ?>')),
                repassword = encodeURIComponent(rsa_encode($("#register-repassword").val(),
                    '<?php echo $bbs_settings['rsa_public']; ?>')),
                qrcode = $("#qrcode3_input").val(),
                flag = false,
                validatecode = null;

            if (username == "") {
                $.pt({
                    target: $("#register-username"),
                    position: 'r',
                    align: 't',
                    width: 'auto',
                    height: 'auto',
                    content: "用户名不能为空"
                });
                flag = true;
            }
            if (password == "") {
                $.pt({
                    target: $("#register-password"),
                    position: 'r',
                    align: 't',
                    width: 'auto',
                    height: 'auto',
                    content: "密码不能为空"
                });
                flag = true;
            }
            if (repassword == "") {
                $.pt({
                    target: $("#register-repassword"),
                    position: 'r',
                    align: 't',
                    width: 'auto',
                    height: 'auto',
                    content: "密码不能为空"
                });
                flag = true;
            }

            if (flag) {
                return false;
            } else { //注册
                $.ajax({
                    type: "POST",
                    url: "<?php echo url('bbs/loginandreg/register'); ?>",
                    data: {
                        email: username,
                        password: password,
                        repassword: repassword,
                        qrcode: qrcode,
                        RegisterCode: RegisterCode,
                    },
                    dataType: "json",
                    success: function (response) {
                        if (response.code == 0) {
                            GetQrcode();

                            spop({
                                template: '<h4 class="spop-title">注册成功</h4>即将于3秒后返回登录',
                                position: 'top-center',
                                style: 'success',
                                autoclose: 3000,
                                onOpen: function () {
                                    var second = 2;
                                    var showPop = setInterval(function () {
                                        if (second == 0) {
                                            clearInterval(showPop);
                                        }
                                        $('.spop-body').html(
                                            '<h4 class="spop-title">注册成功</h4>即将于' +
                                            second +
                                            '秒后返回登录');
                                        second--;
                                    }, 1000);
                                },
                                onClose: function () {
                                    goto_login();
                                    $('#register_page').empty();
                                    $('#register_page').append(
                                        '<img style="width:100%" src="/public/bbs/loginandreg/images/prohibit.png">'
                                    );
                                }
                            });
                        } else {
                            $.pt({
                                target: $("#" + response.tips),
                                position: 'r',
                                align: 't',
                                width: 'auto',
                                height: 'auto',
                                content: response.ErrorMsg
                            });
                        }
                    }
                });
                return false;
            }
        }

        //重置密码
        function forget() {
            var username = $("#forget-username").val(),
                password = $("#forget-password").val(),
                code = $("#forget-code").val(),
                flag = false,
                validatecode = null;
            //判断用户名密码是否为空
            if (username == "") {
                $.pt({
                    target: $("#forget-username"),
                    position: 'r',
                    align: 't',
                    width: 'auto',
                    height: 'auto',
                    content: "用户名不能为空"
                });
                flag = true;
            }
            if (password == "") {
                $.pt({
                    target: $("#forget-password"),
                    position: 'r',
                    align: 't',
                    width: 'auto',
                    height: 'auto',
                    content: "密码不能为空"
                });
                flag = true;
            }
            //用户名只能是15位以下的字母或数字
            var regExp = new RegExp("^[a-zA-Z0-9_]{1,15}$");
            if (!regExp.test(username)) {
                $.pt({
                    target: $("#forget-username"),
                    position: 'r',
                    align: 't',
                    width: 'auto',
                    height: 'auto',
                    content: "用户名必须为15位以下的字母或数字"
                });
                flag = true;
            }
            //检查用户名是否存在
            //调后台方法

            //检查注册码是否正确
            if (code != '11111111') {
                $.pt({
                    target: $("#forget-code"),
                    position: 'r',
                    align: 't',
                    width: 'auto',
                    height: 'auto',
                    content: "注册码不正确"
                });
                flag = true;
            }



            if (flag) {
                return false;
            } else { //重置密码
                spop({
                    template: '<h4 class="spop-title">重置密码成功</h4>即将于3秒后返回登录',
                    position: 'top-center',
                    style: 'success',
                    autoclose: 3000,
                    onOpen: function () {
                        var second = 2;
                        var showPop = setInterval(function () {
                            if (second == 0) {
                                clearInterval(showPop);
                            }
                            $('.spop-body').html('<h4 class="spop-title">重置密码成功</h4>即将于' +
                                second +
                                '秒后返回登录');
                            second--;
                        }, 1000);
                    },
                    onClose: function () {
                        goto_login();
                    }
                });
                return false;
            }
        }
    </script>
    <style type="text/css">
        html {
            width: 100%;
            height: 100%;
        }

        body {

            background-repeat: no-repeat;

            background-position: center center #2D0F0F;

            background-color: #00BDDC;

            background-image: url("/public/bbs/loginandreg/images/snow.jpg");

            background-size: 100% 100%;

        }

        .snow-container {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            pointer-events: none;
            z-index: 100001;
        }
    </style>
</head>

<body>

    <div class="snow-container"></div>

    <div id="login">
        <input id="tab-1" type="radio" name="tab" class="sign-in hidden" checked />
        <input id="tab-2" type="radio" name="tab" class="sign-up hidden" />
        <input id="tab-3" type="radio" name="tab" class="sign-out hidden" />
        <div class="wrapper">

            <div class="login sign-in-htm">
                <form class="container offset1 loginform">

                    <div id="owl-login" class="login-owl">
                        <div class="hand"></div>
                        <div class="hand hand-r"></div>
                        <div class="arms">
                            <div class="arm"></div>
                            <div class="arm arm-r"></div>
                        </div>
                    </div>
                    <div class="pad input-container">
                        <section class="content">
                            <span class="input input--hideo">
                                <input class="input__field input__field--hideo" type="text" id="login-username"
                                    autocomplete="off" placeholder="请输入 用户名/邮箱" tabindex="1" maxlength="60" />
                                <label class="input__label input__label--hideo" for="login-username">
                                    <i class="fa fa-fw fa-user icon icon--hideo"></i>
                                    <span class="input__label-content input__label-content--hideo"></span>
                                </label>
                            </span>
                            <span class="input input--hideo">
                                <input class="input__field input__field--hideo" type="password" id="login-password"
                                    placeholder="请输入密码" tabindex="2" maxlength="60" />
                                <label class="input__label input__label--hideo" for="login-password">
                                    <i class="fa fa-fw fa-lock icon icon--hideo"></i>
                                    <span class="input__label-content input__label-content--hideo"></span>
                                </label>
                            </span>
                            <span class="input input--hideo input--verify_code">
                                <input class="input__field input__field--hideo" type="text" id="login-verify-code"
                                    autocomplete="off" placeholder="请输入验证码" tabindex="3" maxlength="6" />
                                <label class="input__label input__label--hideo" for="login-verify-code">
                                    <i class="fa fa-fw fa-bell-o icon icon--hideo"></i>
                                    <span class="input__label-content input__label-content--hideo"></span>
                                </label>
                            </span>
                            <img src="<?php echo $image; ?>" onclick="GetQrcode()" id="qrcode1" class="verify-code-canvas" alt="验证码">
                        </section>
                    </div>
                    <div class="form-actions">
                        <a tabindex="4" class="btn pull-left btn-link text-muted" onclick="goto_forget()">忘记密码?</a>
                        <a tabindex="5" class="btn btn-link text-muted" onclick="goto_register()">注册</a>
                        <input class="btn btn-primary" type="button" tabindex="3" onclick="login()" value="登录"
                            style="color:white;" />
                    </div>
                </form>
            </div>

            <div class="login sign-out-htm">
                <div class="container offset1 loginform">

                    <div id="owl-login" class="forget-owl">
                        <div class="hand"></div>
                        <div class="hand hand-r"></div>
                        <div class="arms">
                            <div class="arm"></div>
                            <div class="arm arm-r"></div>
                        </div>
                    </div>
                    <div class="pad input-container">
                        <section class="content">
                            <span class="input input--hideo input--verify_code">
                                <input class="input__field input__field--hideo" type="text" id="Retrieve_Email"
                                    autocomplete="off" placeholder="请输入邮箱" maxlength="60" />
                                <label class="input__label input__label--hideo" for="Retrieve_Email">
                                    <i class="fa fa-envelope-o fa-fw icon icon--hideo"></i>
                                    <span class="input__label-content input__label-content--hideo"></span>
                                </label>
                            </span>
                            <button class="verify-code-button" id="Button_Retrieve_Email"
                                onclick="GetCode('Retrieve_Email')">获取验证码</button>

                            <span class="input input--hideo">
                                <input class="input__field input__field--hideo" type="text" id="Retrieve_code"
                                    autocomplete="off" placeholder="请输入获取到的验证码" />
                                <label class="input__label input__label--hideo" for="Retrieve_code">
                                    <i class="fa fa-fw fa-code icon icon--hideo"></i>
                                    <span class="input__label-content input__label-content--hideo"></span>
                                </label>
                            </span>
                            <span class="input input--hideo">
                                <input class="input__field input__field--hideo" type="text" id="forget-code"
                                    autocomplete="off" placeholder="请输入注册码" />
                                <label class="input__label input__label--hideo" for="forget-code">
                                    <i class="fa fa-fw fa-wifi icon icon--hideo"></i>
                                    <span class="input__label-content input__label-content--hideo"></span>
                                </label>
                            </span>
                            <span class="input input--hideo">
                                <input class="input__field input__field--hideo" type="password" id="forget-password"
                                    placeholder="请重置密码" />
                                <label class="input__label input__label--hideo" for="forget-password">
                                    <i class="fa fa-fw fa-lock icon icon--hideo"></i>
                                    <span class="input__label-content input__label-content--hideo"></span>
                                </label>
                            </span>
                            <span class="input input--hideo input--verify_code">
                                <input class="input__field input__field--hideo" type="text" id="login-verify-code"
                                    autocomplete="off" placeholder="请输入验证码" tabindex="3" maxlength="6" />
                                <label class="input__label input__label--hideo" for="login-verify-code">
                                    <i class="fa fa-fw fa-bell-o icon icon--hideo"></i>
                                    <span class="input__label-content input__label-content--hideo"></span>
                                </label>
                            </span>
                            <img src="<?php echo $image; ?>" onclick="GetQrcode()" id="qrcode2" class="verify-code-canvas" alt="验证码">
                        </section>
                    </div>
                    <div class="form-actions">
                        <a class="btn pull-left btn-link text-muted" onclick="goto_login()">返回登录</a>
                        <input class="btn btn-primary" type="button" onclick="forget()" value="重置密码"
                            style="color:white;" />
                    </div>
                </div>
            </div>

            <div class="login sign-up-htm">
                <div class="container offset1 loginform">

                    <div id="owl-login" class="register-owl">
                        <div class="hand"></div>
                        <div class="hand hand-r"></div>
                        <div class="arms">
                            <div class="arm"></div>
                            <div class="arm arm-r"></div>
                        </div>
                    </div>
                    <div id='register_page' class="pad input-container">
                        <section class="content">
                            <span class="input input--hideo input--verify_code">
                                <input class="input__field input__field--hideo" type="text" id="Register_Email"
                                    autocomplete="off" placeholder="请输入邮箱" maxlength="60" />
                                <label class="input__label input__label--hideo" for="Register_Email">
                                    <i class="fa fa-envelope-o fa-fw icon icon--hideo"></i>
                                    <span class="input__label-content input__label-content--hideo"></span>
                                </label>
                            </span>
                            <button class="verify-code-button" id="Button_Register_Email"
                                onclick="GetCode('Register_Email')">获取验证码</button>

                            <span class="input input--hideo">
                                <input class="input__field input__field--hideo" type="text" id="register-code"
                                    autocomplete="off" placeholder="请输入获取到的验证码" />
                                <label class="input__label input__label--hideo" for="register-code">
                                    <i class="fa fa-fw fa-code icon icon--hideo"></i>
                                    <span class="input__label-content input__label-content--hideo"></span>
                                </label>
                            </span>

                            <span class="input input--hideo">
                                <input class="input__field input__field--hideo" type="password" id="register-password"
                                    placeholder="请输入密码" maxlength="60" />
                                <label class="input__label input__label--hideo" for="register-password">
                                    <i class="fa fa-fw fa-lock icon icon--hideo"></i>
                                    <span class="input__label-content input__label-content--hideo"></span>
                                </label>
                            </span>
                            <span class="input input--hideo">
                                <input class="input__field input__field--hideo" type="password" id="register-repassword"
                                    placeholder="请确认密码" maxlength="60" />
                                <label class="input__label input__label--hideo" for="register-repassword">
                                    <i class="fa fa-fw fa-lock icon icon--hideo"></i>
                                    <span class="input__label-content input__label-content--hideo"></span>
                                </label>
                            </span>
                            <span class="input input--hideo input--verify_code">
                                <input class="input__field input__field--hideo" type="text" id="qrcode3_input"
                                    autocomplete="off" placeholder="请输入验证码" maxlength="6" />
                                <label class="input__label input__label--hideo" for="login-verify-code">
                                    <i class="fa fa-fw fa-bell-o icon icon--hideo"></i>
                                    <span class="input__label-content input__label-content--hideo"></span>
                                </label>
                            </span>
                            <img src="<?php echo $image; ?>" onclick="GetQrcode()" id="qrcode3" class="verify-code-canvas" alt="验证码">

                        </section>
                    </div>
                    <div class="form-actions">
                        <a class="btn pull-left btn-link text-muted" onclick="goto_login()">返回登录</a>
                        <input class="btn btn-primary" type="button" onclick="register()" value="注册"
                            style="color:white;" />
                    </div>
                </div>
            </div>
        </div>
    </div>
</body>

</html>